package com.wave.waveoss.config;

import com.wave.waveoss.client.WaveOssClient;
import io.minio.MinioClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConfigurationProperties(prefix = "wave.minio")
@Data
@EnableConfigurationProperties
public class WaveMinioConfig {

    private String accessKey;

    private String secretKey;

    private String endpoint;

    private String bucket;

    @Bean
    public MinioClient minioClient() {
        return MinioClient.builder()
                .endpoint(endpoint)
                .credentials(accessKey, secretKey)
                .build();
    }

    @Bean
    public WaveOssClient waveOssClient(MinioClient minioClient) {
        return new WaveOssClient(minioClient, endpoint, bucket);
    }

}
